"""
example09 - 用一个列表保存54张扑克牌，先洗牌，
再按斗地主的发牌方式把牌发给三个玩家，多的3张拍给第一个玩家（地主），
最后把每个玩家手上的牌显示出来。

Author: Administrator
Date: 2024/1/9
"""
import random


suites = ['♠', '♥', '♣', '♦']
faces = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
# cards = []
# for suite in suites:
#     for face in faces:
#         cards.append(f'{suite}{face}')
cards = [f'{suite}{face}' for suite in suites for face in faces]
cards.append('小王')
cards.append('大王')

random.shuffle(cards)

player_one = []
player_two = []
player_three = []

for _ in range(17):
    player_one.append(cards.pop())
    player_two.append(cards.pop())
    player_three.append(cards.pop())

player_one += cards

player_one.sort(key=lambda x: x[2:])
player_two.sort(key=lambda x: x[2:])
player_three.sort(key=lambda x: x[2:])

for card in player_one:
    print(card, end=' ')
print()
for card in player_two:
    print(card, end=' ')
print()
for card in player_three:
    print(card, end=' ')
print()